//  Convert this program to C++
//  change to C++ io
//  change to one line comments
//  change defines of constants to const
//  change array to vector<>
//  inline any short function
#include <iostream>
#include <vector>
using namespace std;
const int N = 5;
inline void sum(int *p, int n, vector<int> &d)
{
    *p = 0;
    // iterate vector and calculate sum of elements
    for(vector<int>::iterator it = d.begin(); it < d.end(); it++)
        *p = *p + *it;
}
int main()
{
    int accum = 0;
    vector<int> data;
    // populate vector
    for(int i = 0; i < N; ++i)
        data.push_back(i);
    // calculate sum of vector elements
    sum(&accum, N, data);
    // print result
    cout << "sum is " << accum << endl;
    return 0;    
}


